import java.util.Scanner;


public class SecuredNotepad extends SimpleNotepad
{
	private String password;
	Scanner passScan = new Scanner(System.in);

	public SecuredNotepad(int pages, String password) 
	{
		super(pages);
		this.password = password;
	}
	
	@Override
	public void addText(String text, int pageNumber) 
	{
		if(validatePassword())
			super.addText(text, pageNumber);
	}

	@Override
	public void setText(String text, int pageNumber)
	{
		if(validatePassword())
			super.setText(text, pageNumber);
	}

	@Override
	public void deleteText(int pageNumber) 
	{
		if(validatePassword())
			super.deleteText(pageNumber);
	}

	@Override
	public void viewNotePad() 
	{
		if(validatePassword())
			super.viewNotePad();
	}
	
	private boolean validatePassword()
	{
		System.out.println("Enter password:");
		String inputPass = passScan.next();
		if(this.password.equals(inputPass))
			return true;
		else
		{
			System.out.println("Wrong password!");
			return false;
		}
	}
	
}
